package com.example.limit.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Data
@ConfigurationProperties(prefix = "rate.limiter")
@Configuration
public class RateLimiterConfig {
    // 模块限流配置
    private Map<String, ModuleConfig> modules = new HashMap<>();
    
    // 是否启用分布式限流
    private boolean distributedEnabled = true;
    
    // 降级策略
    private DegradeStrategy degradeStrategy = DegradeStrategy.LOCAL_ONLY;
    
    @Data
    public static class ModuleConfig {
        private String name;
        private int qps;
        private boolean enabled = true;
    }
    
    public enum DegradeStrategy {
        LOCAL_ONLY,      // 仅本地限流
        PASS_THROUGH,    // 直接通过
        REJECT_ALL       // 全部拒绝
    }
}



